package sg.edu.nus.iss.ooad.jass.entity;

/**
 *
 * @author WangJuan
 */
public class LoginInfo {

        private static LoginInfo login = null;
        private static String loginId = "";
        private static int loginDomain = -1;
        //Domain for Login
        public final static int UNKNOWN = -1;
        public final static int JOBSEEKER = 0;
        public final static int JOBADVERTISER = 1;
        public final static int SYSTEMADMINISTRATOR = 2;

        /**
         *
         */
        public LoginInfo() {
        }

        /**
         * 
         * @param loginId
         * @param loginDomain
         */
        public LoginInfo(String loginId, int loginDomain) {
                LoginInfo.loginId = loginId;
                LoginInfo.loginDomain = loginDomain;
        }

        /**
         *
         * @param loginId
         * @param loginDomain
         * @return
         */
        public static LoginInfo getInstance(String loginId, int loginDomain) {
                if (login == null) {
                        return new LoginInfo(loginId, loginDomain);
                } else {
                        return login;
                }
        }

        /**
         *
         * @return
         */
        public static String getLoginId() {
                return loginId;
        }

        /**
         *
         * @param loginId
         */
        public void setLoginId(String loginId) {
                LoginInfo.loginId = loginId;
        }

        /**
         *
         * @return
         */
        public static int getLoginDomain() {
                return loginDomain;
        }

        /**
         *
         * @param loginDomain
         */
        public void setLoginDomain(int loginDomain) {
                LoginInfo.loginDomain = loginDomain;
        }

        /**
         * 
         * @param loginDomain
         * @return
         */
        public static boolean isJobseeker(int loginDomain) {
                return loginDomain == JOBSEEKER;
        }

        /**
         *
         * @param loginDomain
         * @return
         */
        public static boolean isAdvertiser(int loginDomain) {
                return loginDomain == JOBADVERTISER;
        }

        /**
         * 
         * @param loginDomain
         * @return
         */
        public static boolean isSystemAdmin(int loginDomain) {
                return loginDomain == SYSTEMADMINISTRATOR;
        }
}
